package com.ztgf.commodity.api.cms;

import com.baomidou.mybatisplus.plugins.Page;
import com.ztgf.commodity.models.bo.CommodityEvaluationManageBO;
import com.ztgf.commodity.models.service.ICommodityEvaluationService;
import com.ztgf.commodity.models.vo.CommodityEvaluationManageVO;
import com.ztgf.commodity.models.vo.CommodityEvaluationPageVO;
import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品评价表控制器
 *
 * @author chenyu.wang
 * @Date 2020-05-29 15:18:55
 */

@RestController
@RequestMapping("/cms/commodityEvaluation")
@Slf4j
@Api(value = "CommodityEvaluationController", tags = "商品评价表接口")
public class CommodityEvaluationController {

    @DubboReference
    private ICommodityEvaluationService commodityEvaluationService;

    @PostMapping("/queryEvaluationManageList")
    @ApiOperation(value = "评价管理列表", notes = "评价管理列表")
    public Result queryEvaluationManageList(CommodityEvaluationManageBO bo) {
        Page<CommodityEvaluationManageVO> page = commodityEvaluationService.queryEvaluationManageList(bo);
        return new Result<>(page);
    }

    @PostMapping("/getViewEvaluationById")
    @ApiOperation(value = "查看评价详情", notes = "查看评价详情")
    @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query", dataType = "Long")
    public Result get(Long id) {
        if (id == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        CommodityEvaluationPageVO evaluation = commodityEvaluationService.getViewEvaluationById(id);
        return new Result<>(evaluation);
    }

}
